package com.wqj.kyee.gps.bluetooth

import android.support.v4.content.ContextCompat
import android.view.View
import android.widget.AdapterView
import org.jetbrains.anko.*

/**
 * Created by kyee on 17-12-8.
 */
class BtDevicesUi : AnkoComponent<BtDevicesActivity> {
    val items = arrayOf("NFC","WLAN","LCD屏","触摸屏","音频","摄像头","按钮")

    override fun createView(ui: AnkoContext<BtDevicesActivity>): View {
        return with(ui) {
            verticalLayout {
                padding = dip(16)
                backgroundColor = ContextCompat.getColor(ui.ctx, android.R.color.white)
                listView() {
                    id = ID_BT_DEVICES_LIST
                    adapter = BtDevicesActivity.btDevicesAdapter
                    onItemClickListener = object : AdapterView.OnItemClickListener {
                        override fun onItemClick(parent: AdapterView<*>?, v: View?
                                                 , position: Int, id: Long) {
                            when (position) {
                                0 -> {
                                    // startActivity<BTDevicesActivity>()
                                }
                            }
                        }
                    }
                }.lparams(width = matchParent) {
                    height = matchParent
                }
            }
        }
    }

    companion object {
        val ID_BT_DEVICES_LIST: Int = 0
    }
}